import React, { Component } from "react";
import { StyleSheet, Text, View } from "react-native";
import NavigationUtil from "../navigator/NavigationUtil";
import { getBoarding } from '../util/BoardingUtil'
import SplashScreen from 'react-native-splash-screen'
export default class WelcomePage extends Component {
    componentDidMount(){
        SplashScreen.hide();
        this.doLaunch();
    }

    componentWillUnmount(){
        this.timer && clearTimeout(this.timer)
    }

    async doLaunch() {
        const boarding = await getBoarding();
        const { navigation } = this.props;
        this.timer = setTimeout(() => {
            if (boarding) {
                NavigationUtil.resetHomePage({ navigation })
            } else {
                NavigationUtil.goLogin({ navigation })
            }
        }, 200);
    }

    render() {
        return (
            <View style={styles.container}>
                <Text>欢迎页</Text>
            </View>
        )
    }
}

const styles = StyleSheet.create({
    container: {
        flex: 1,
    }
})